﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.ComponentModel;

namespace YJYpublicClass
{
    public class point
    {
     [Category("点"), Description("double类型"), DisplayName("x"), ReadOnly(false)]
      public double x { get; set; }
     [Category("点"), Description("double类型"), DisplayName("y"), ReadOnly(false)]
     public double y { get; set; }
     [Category("点"), Description("double类型"), DisplayName("r"), ReadOnly(false)]
     public double r { get; set; }
      public  point()
     {
         x = 0.0;
         y = 0.0;
         r = 0.0;
     }
    }
    public class RunResult
    {
        public string StrBarcode;       
        public double ZZX1;
        public double ZZY1;
        public double ZZT1;

        public double ZZSendX1;
        public double ZZSendY1;
        public double ZZSendZ1;
        public double ZZSendT1;

        public double ZZX2;
        public double ZZY2;
        public double ZZT2;

        public double ZZSendX2;
        public double ZZSendY2;
        public double ZZSendZ2;
        public double ZZSendT2;
       

        public double dR_FirstPointFitCircle;
        public double dAngle_Axis;
        public double dDeltaX;
        public double dDeltaY;
        public double[] dDistance = new double[4];

        public double SNQ_AX;
        public double SNQ_AY;
        public double SNQ_AT;

        public double SNQ_ASendX;
        public double SNQ_ASendY;
        public double SNQ_ASendZ;
        public double SNQ_ASendT;

        public double SNQ_BX;
        public double SNQ_BY;
        public double SNQ_BT;

        public double SNQ_BSendX;
        public double SNQ_BSendY;
        public double SNQ_BSendZ;
        public double SNQ_BSendT;

        public double SNQ_CX;
        public double SNQ_CY;
        public double SNQ_CT;

        public double SNQ_CSendX;
        public double SNQ_CSendY;
        public double SNQ_CSendZ;
        public double SNQ_CSendT;

        public double SNQ_DX;
        public double SNQ_DY;
        public double SNQ_DT;

        public double SNQ_DSendX;
        public double SNQ_DSendY;
        public double SNQ_DSendZ;
        public double SNQ_DSendT;
    }                     
    //九点标定参数
    public class NTNCalibData
    {

        public double[] Pixel_X { get; set; }
        public double[] Pixel_Y { get; set; }
        public double[] Robot_X { get; set; }
        public double[] Robot_Y { get; set; }
        public NTNCalibData()
        {
            Pixel_X = new double[9];
            Pixel_Y = new double[9];
            Robot_X = new double[9];
            Robot_Y = new double[9];
            for (int i = 0; i < 9; i++)
            {
                Pixel_X[i] = 0.0;
                Pixel_Y[i] = 0.0;
                Robot_X[i] = 0.0;
                Robot_Y[i] = 0.0;
            }

        }
    }
    //旋转中心标定参数
    public class FitCircleData
    {

        public double[] Pixel_X { get; set; }
        public double[] Pixel_Y { get; set; }
        public double[] Robot_X { get; set; }
        public double[] Robot_Y { get; set; }
        public double[] Robot_R { get; set; }
        public FitCircleData()
        {
            Pixel_X = new double[9];
            Pixel_Y = new double[9];
            Robot_X = new double[9];
            Robot_Y = new double[9];
            Robot_R = new double[9];
            for (int i = 0; i < 9; i++)
            {
                Pixel_X[i] = 0.0;
                Pixel_Y[i] = 0.0;
                Robot_X[i] = 0.0;
                Robot_Y[i] = 0.0;
                Robot_R[i] = 0.0;
            }

        }
    }
    //基准坐标参数
    public class BaiscPointData
    {
        //
        [TypeConverter(typeof(ExpandableObjectConverter))]
        [EditorBrowsable(EditorBrowsableState.Always)]
        [Category("基准点"), Description("点类型"), DisplayName("旋转中心机械基准位"), ReadOnly(false)]
        public point CircleRobotBP { get; set; }
        [TypeConverter(typeof(ExpandableObjectConverter))]
        [EditorBrowsable(EditorBrowsableState.Always)]
        [Category("基准点"), Description("点类型"), DisplayName("旋转中心拟合基准位"), ReadOnly(false)]
        public point CircleRobotFitBP { get; set; }
        [TypeConverter(typeof(ExpandableObjectConverter))]
        [EditorBrowsable(EditorBrowsableState.Always)]
        [Category("基准点"), Description("点类型"), DisplayName("抓取机械基准位"), ReadOnly(false)]
        public point GrabBP { get; set; }
        [TypeConverter(typeof(ExpandableObjectConverter))]
        [EditorBrowsable(EditorBrowsableState.Always)]
        [Category("基准点"), Description("点类型"), DisplayName("抓取模板基准位"), ReadOnly(false)]
        public point GrabModelBP { get; set; }
        //
        public BaiscPointData()
        {
            CircleRobotBP = new point();
            CircleRobotFitBP = new point();
            GrabBP = new point();
            GrabModelBP = new point();
        }
    }
    //辅助标定参数
    public class AssitCalibData
    {
        //九点标定起始辅助位置
        public point NTNCalibAP = new point();
        //生成坐标点间隔
        public double Xinterval = 0.0;
        public double Yinterval = 0.0;

        //旋转中心标定辅助机械位置
        public point FitCircleAP = new point();
        //旋转中心标定辅助间隔
        public double Rinterval = 0.0;
    }
    //参数打包集合
    public class CalibDataList
    {
        public NTNCalibData NCD = new NTNCalibData();
        public FitCircleData FCD = new FitCircleData();
        public BaiscPointData BPD = new BaiscPointData();
        public AssitCalibData ACD = new AssitCalibData();
        public OffsetData OFD = new OffsetData();
    }
    //补偿参数
    public class OffsetData
    {
        [Category("补偿参数"), Description("double类型"), DisplayName("X补偿"), ReadOnly(false)]
        public double Offeset_X { get; set; }
        [Category("补偿参数"), Description("double类型"), DisplayName("Y补偿"), ReadOnly(false)]
        public double Offeset_Y { get; set; }

        [Category("补偿参数"), Description("double类型"), DisplayName("R补偿"), ReadOnly(false)]
        public double Offeset_R { get; set; }
        public OffsetData()
        {
            Offeset_X = 0.0;
            Offeset_Y = 0.0;
            Offeset_R = 0.0;
        }
    }
    public class SysDate
    {
        [Category("MES参数"), Description("string类型"), DisplayName("料盘码"), ReadOnly(false)]
        public string StrTrayCode { get; set; }

        [Category("MES参数"), Description("bool类型"), DisplayName("是否上传Mes"), ReadOnly(false)]
        public bool bisUpMes { get; set; }

        [Category("MES参数"), Description("string类型"), DisplayName("线体ID"), ReadOnly(false)]
        public string LineID { get; set; }

        [Category("MES参数"), Description("string类型"), DisplayName("工站ID"), ReadOnly(false)]
        public string StationID { get; set; }

        [Category("通讯参数"), Description("string类型"), DisplayName("PLC的主站IP"), ReadOnly(false)]
        public string PLCRemoteIP { get; set; }

        [Category("通讯参数"), Description("int类型"), DisplayName("端口号"), ReadOnly(false)]
        public int PLCPort { get; set; }

        [Category("通讯参数"), Description("string类型"), DisplayName("PC的IP"), ReadOnly(false)]
        public string PCIP { get; set; }

        #region【机械手】
        [Category("串口通讯参数"), Description("string类型"), DisplayName("串口号"), ReadOnly(false)]
        public string _SerialCom { get; set; }

        [Category("串口通讯参数"), Description("string类型"), DisplayName("波特率"), ReadOnly(false)]
        public int _SerialComBaud { get; set; }

        [Category("串口通讯参数"), Description("string类型"), DisplayName("触发拍照命令1"), ReadOnly(false)]
        public string Robot_CmdA { get; set; }


        [Category("串口通讯参数"), Description("string类型"), DisplayName("触发拍照命令2"), ReadOnly(false)]
        public string Robot_CmdB { get; set; }



        [Category("串口通讯参数"), Description("string类型"), DisplayName("触发拍照命令3"), ReadOnly(false)]
        public string Robot_CmdC { get; set; }



        [Category("串口通讯参数"), Description("string类型"), DisplayName("触发拍照命令4"), ReadOnly(false)]
        public string Robot_CmdD { get; set; }


       
        #endregion
       
        [Category("存图配置"), Description("Bool类型"), DisplayName("是否保存Tray盘图片"), ReadOnly(false)]
        public bool bisSaveNGJDImg { get; set; }
        [Category("存图配置"), Description("Bool类型"), DisplayName("是否保存吸嘴1定位图片"), ReadOnly(false)]
        public bool bisSaveNGDKImg { get; set; }
        [Category("存图配置"), Description("Bool类型"), DisplayName("是否保存吸嘴2定位图片"), ReadOnly(false)]
        public bool bisSaveNGXZImg2 { get; set; }
        [Category("存图配置"), Description("Bool类型"), DisplayName("是否保存组装1定位图片"), ReadOnly(false)]
        public bool bisSaveNGZZDownImg { get; set; }
        [Category("存图配置"), Description("Bool类型"), DisplayName("是否保存组装2定位图片"), ReadOnly(false)]
        public bool bisSaveNGZZUpImg { get; set; }

        [Category("存图配置"), Description("int类型"), DisplayName("保存图片天数"), ReadOnly(false)]
        public int DaysSavedImage { get; set; }

        
        [Category("重测配置"), Description("Bool类型"), DisplayName("取脚垫NG后是否重测"), ReadOnly(false)]
        public bool bQJDRetry { get; set; }
        [Category("重测配置"), Description("Bool类型"), DisplayName("上底壳NG后是否重测"), ReadOnly(false)]
        public bool bSDKRetry2 { get; set; }
        [Category("重测配置"), Description("Bool类型"), DisplayName("脚垫检测NG后是否重测"), ReadOnly(false)]
        public bool bJDLocationRetry { get; set; }
        [Category("重测配置"), Description("Bool类型"), DisplayName("组装下NG后是否重测"), ReadOnly(false)]
        public bool bZZDownRetry { get; set; }
        [Category("NG数据统计"), Description("Bool类型"), DisplayName("是否启用NG数据自动清零（早/晚8点）"), ReadOnly(false)]
        public bool bAutoCloerNGData { get; set; }
        [Category("NG数据统计"), Description("int类型"), DisplayName("底壳NG"), ReadOnly(true)]
        public int nDKNG { get; set; }
        [Category("NG数据统计"), Description("int类型"), DisplayName("脚垫NG"), ReadOnly(true)]
        public int nJDNG { get; set; }
        [Category("NG数据统计"), Description("int类型"), DisplayName("组装上NG"), ReadOnly(true)]
        public int nZZUpNG { get; set; }
        [Category("NG数据统计"), Description("int类型"), DisplayName("组装下NG"), ReadOnly(true)]
        public int nZZDownNG { get; set; }
        [Category("NG数据统计"), Description("int类型"), DisplayName("扫码NG"), ReadOnly(true)]
        public int nCodeNG { get; set; }

        [Category("屏蔽扫码"), Description("bool类型"), DisplayName("是否屏蔽扫码"), ReadOnly(false)]
        public bool bisPbCode { get; set; }

        public SysDate()
        {
            PLCRemoteIP = "192.168.0.5";
            PLCPort = 9600;
            PCIP = "192.168.0.30";
            nDKNG = 0;
            nJDNG = 0;
            nZZUpNG = 0;
            nZZDownNG = 0;
            nCodeNG = 0;
            bisSaveNGJDImg = true;         
            bisSaveNGDKImg = true;
            bisSaveNGZZDownImg = true;
            bisSaveNGZZUpImg = true;        
            bQJDRetry = true;
            bSDKRetry2 = true;
            bJDLocationRetry = true;
            bZZDownRetry = true;
        }
    }
  
}
